<template>
	<view class="feedback">
		<view class="formBox">
			<view class="item">
				<textarea class="textarea" v-model="form.content" placeholder="请输入您遇到的问题或您的意见" placeholder-class="placeholderClase"/>
			</view>
			<view class="item mTop2">
				<view class="label">联系方式</view>
				<view class="inputBox flex1">
					<input class="input" type="text" v-model="form.phone" placeholder="请如实填写" placeholder-class="placeholderClase"/>
				</view>
			</view>
		</view>
		<view class="bottomBox mTop5">
			<button class="btn" type="default" hover-class="none" @click="submit">确认提交</button>
		</view>
	</view>
</template>

<script>
	var util = require('../../common/util.js');
	import { encryptData, decryptedData } from '../../utils/crypto.js'

	export default {
		data() {
			return {
				form: {
					content: '',
					phone: '',
				},
				parent_user:''
			}
		},
		onLoad(e) {
			console.log(e);
			if(uni.getStorageSync('schoolId') && uni.getStorageSync('schoolId') != ''){
				this.parent_user = uni.getStorageSync('schoolId')
			}else{
				this.parent_user = e.parent_user;
			}
		},
		methods: {
			submit () {
				let form = Object.assign({}, this.form)
				let phone = encryptData(form.phone)
				form.phone = phone
				
				util.requestPost('user/feedBack', {
					form:JSON.stringify(form),
					parent_user:this.parent_user,
				}, (res) => {
					if (res.code == 1) {
						console.log(res);
						this.$toast(res.msg)
						setTimeout(() => {
							uni.navigateTo({
								url:'/pages/my/my?parent_user=' + this.parent_user,
							})
						}, 500);
					} else {
						this.$toast(res.msg)
					}
				}, (err) => {
					console.log(err);
				}, {isShowLoading: false});
			}
		}
	}
</script>

<style scoped lang="scss">
.feedback {
	padding: 20rpx;
	.formBox {
		.item {
			border: $border-base;
			border-radius: 12rpx;
			display: flex;
			align-items: stretch;
			.label {
				width: 280rpx;
				font-size: 28rpx;
				text-align: center;
				height: 68rpx;
				line-height: 68rpx;
				border-right: $border-base;
				background-color: $bg-color;
			}
			.textarea {
				padding: 20rpx;
				width: 100%;
			}
		}
		.inputBox {
			.input {
				font-size: 28rpx;
				height: 68rpx;
				line-height: 68rpx;
				padding: 0 20rpx;
			}
			.input-icon {
				margin: 0 20rpx;
			}
			.picker-input {
				pointer-events: none;
			}
		}
		.placeholderClase {
			font-size: 24rpx;
		}
	}
	.bottomBox {
		.btn {
			color: #FFFFFF;
			font-size: 28rpx;
			line-height: 76rpx;
			border-radius: 20rpx;
			background: $btn-bg-color;
			&::after {
				border: none;
			}
		}
	}
}
</style>
